<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="活动管理">

    <!--suppress ALL -->
    <form id="searchForm" class="form-panel" action="${basepath}/rest/manage/activity/selectActivityPicturePage">
        <ul class="panel-content">
            <li>
                <div class="control-group span5" style="  line-height: 54px;">
                    <div class="search-controls  controls">
                        <input type="text" name="nickname" id="nickname" value="" placeholder="搜索关键字" class="bui-form-field" aria-disabled="false" aria-pressed="false">
                    </div>
                </div>
                <div class="form-actions span2">
                    <button type="submit" class="button  button-primary">
                        搜索
                    </button>
                </div>
                <div class="form-actions span6">
                    <a class="button button-danger" href="javascript:delFunction()">批量删除</a>
                </div>
            </li>
        </ul>
    </form>
    <div id="grid"></div>
<script>
    var Grid = BUI.Grid,
            Store = BUI.Data.Store,
            columns = [
                {title: '序号', dataIndex: 'id', elCls: 'center', width: '5%'},
                {title : '活动名称',dataIndex :'activityName',  elCls: 'center', width:'16%'},
                {title : '上传日期',dataIndex :'createTime',  elCls: 'center', width:'16%'},
                {title : '上传者',dataIndex :'nickname',  elCls: 'center', width:'16%'},
                {title : '是否报名过该活动',dataIndex :'userName',  elCls: 'center', width:'16%',renderer:function (value) {
                        value=value?'否':'是';
                        return value;
                    }},
                {title : '审核状态',dataIndex :'status',  elCls: 'center', width:'16%',renderer:function (value) {
                        value=value=='init'?'待审核':value=='pass'?'通过':'不通过';
                        return value;
                    }},
                {title : '操作',dataIndex :'id', elCls: 'center', width:'16%',renderer:function(value,data){
                        var option1 = '<a href="${basepath}/rest/manage/activity/toActivityPictureCheck?id=' + value +' +&name='+data.nickname+'">审核</a>';
                        var option2 = '<a href="javascript:deleteOne(' + value + ')">删除</a>';
                        return option1 + "&nbsp;&nbsp;&nbsp;&nbsp;" + option2;
                    }},

            ];
    var activityID=getQueryString('id');
    var store = new Store({
                url: '/rest/manage/activity/selectActivityPicturePage',
                autoLoad: true, //自动加载数据
                params: { //配置初始请求的参数
                    length: '10',
                    activityID: activityID
                },
                pageSize: 10,	// 配置分页数目
                root: 'list',
                totalProperty: 'total'
            }),
      grid = new Grid.Grid({
                render:'#grid',
                columns : columns,
                loadMask: true, //加载数据时显示屏蔽层
                store: store,
                plugins : [Grid.Plugins.CheckSelection], // 插件形式引入多选表格
                // 底部工具栏
                bbar:{
                    pagingBar:true
                }
            });

    grid.render();
    /*--------------------------------模糊查询---------------------------------------------*/
    var form = new BUI.Form.HForm({
        srcNode: '#searchForm'
    }).render();

    form.on('beforesubmit', function (ev) {
        //序列化成对象
        var obj = form.serializeToObject();
        obj.start = 0; //返回第一页
        store.load(obj);
        return false;
    });
    //删除单个
    function deleteOne(id) {
        BUI.Message.Confirm('确认要删除吗？', function () {   //双选框
            $.ajax({
                type: "POST",                                //传输方法
                url: "${basepath}/rest/manage/activitypicture/deleteJson",  //删除
                dataType: "json",                            //数据类型
                data: {
                    id: id                                //向后端传的数据
                },
                success: function (data) {
                    var obj = form.serializeToObject();      //将表单格式化成键值对形式
                    obj.start = 0;                          //返回第一页
                    store.load(obj);
                }
            });
        },'question')
    }

    //删除选中的记录
    function delFunction(){
        var selections = grid.getSelection();
        var ids=new Array();
        for(var i=0;i<selections.length;i++){
            ids[i]=selections[i].id.toString()
        }
        $.ajax({
            type: "POST",
            url: "${basepath}/rest/manage/activitypicture/deletesJson",
            dataType: "json",
            data: {
                ids:ids
            },
            success: function (data) {
                var obj = new Object();
                obj.start = 0; //返回第一页
                store.load(obj);
            }
        });

    }
</script>

</@page.pageBase>
